<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<div class="container-fluid " id="info" style="margin-top: 30px;margin-bottom: 40px;">

		<div class="row">
		<nav class="navbar navbar-expand-sm bg-secondary navbar-dark fixed-top" style="margin-right: 0px">
		<img class="navbar-brand" src="/img/logo1.png" style="width:45px;height:45px">
			 <div class="col-lg-4">
			<ul class="navbar-nav">
				<li class="nav-item"><a class="nav-link font-weight-bold"
					href="/zlz/main.html">主页</a></li>
				<li class="nav-item"><a class="nav-link font-weight-bold"
					href="/zlz/focus.html">关注</a></li>
				<li class="nav-item"><a class="nav-link font-weight-bold"
					href="#" @click.prevent="toAdvice">通知<small class="text-danger font-italic">&nbsp{{content}}</small></a></li>
				<li class="nav-item dropdown" ><a class="nav-link font-weight-bold dropdown-toggle" id="navbardrop" data-toggle="dropdown"
					href="#">个人中心</a>
					 <div class="dropdown-menu" v-if="role=='student'">
				        <a class="dropdown-item" href="/zlz/myfriends.html">我的好友</a>
				        <a class="dropdown-item" href="/zlz/mywallet.html">我的钱包</a>
				        <a class="dropdown-item" href="/lsw/detail.html">信息完善</a>
				        <a class="dropdown-item" href="/lsw/myorders.html">我的订单</a>
				        <a class="dropdown-item" href="/zlz/change_pwd.html">密码修改</a>
				      </div>
					 <div class="dropdown-menu" v-if="role=='coach'">
				        <a class="dropdown-item" href="/zlz/my_student.html">我的学员</a>
				        <a class="dropdown-item" href="/zlz/focus_me.html">关注我的</a>
				        <a class="dropdown-item" href="/zlz/mywallet.html">我的钱包</a>
				        <a class="dropdown-item" href="/lsw/myorders.html">我的订单</a>
				        <a class="dropdown-item" href="/zlz/addCourse.html">添加课程</a>
				        <a class="dropdown-item" href="/lsw/detail.html">信息完善</a>
				        <a class="dropdown-item" href="/lsw/mysign.html">我的签约</a>
				        <a class="dropdown-item" href="/zlz/change_pwd.html">密码修改</a>
				      </div>
					 <div class="dropdown-menu" v-if="role=='gym'">
				        <a class="dropdown-item" href="/zlz/focus_me.html">关注我的</a>
				        <a class="dropdown-item" href="/zlz/mywallet.html">我的钱包</a>
				        <a class="dropdown-item" href="/zlz/addCourse.html">添加课程</a>
				        <a class="dropdown-item" href="javascript:;" @click=toMycourse>我的课程</a>
				        <a class="dropdown-item" href="/cyh/arrangeCourses.html">安排课程</a>
				        <a class="dropdown-item" href="/cyh/detail.html">信息完善</a>
				        <a class="dropdown-item" href="/cyh/mySignCoaches.html">我的签约教练</a>
				        <a class="dropdown-item" href="/cyh/employeeList2.html">我的签约申请</a>
				        <a class="dropdown-item" href="/zlz/change_pwd.html">密码修改</a>
				      </div>
				</li>
			</ul>
			</div>
			<div class="col-lg-8">
			<div class="text-primary" style="float:right;">
				<img alt="" :src="avatar" class="rounded-circle" style="width:25px;height:25px">
				<label>{{nickname}}</label>
				<a href="/home/logout" class="btn">注销</a>
			</div>
			</div>
		</nav>
		</div>
	</div>
<script>
	var header = new Vue({
		el:"#info",
		data:{
			nickname:"",
			content:"",
			timer:null,
			role:"",
			avatar:"",
			id:""
			
		},
		mounted(){
			axios.get("/coach/getNowUser")
				.then(
					res => {
						if(res.data.code==200){
							this.nickname=res.data.data.nickname;
							this.avatar=res.data.data.avatar;
							this.id = res.data.data.id;
							console.log(this.avatar);
							if(res.data.data.role==1){
								this.role="student";
							}else if(res.data.data.role==2){
								this.role="coach";
							}else if(res.data.data.role==3){
								this.role="gym";
							}
						}
					}
			);
			this.getNewAdvice();
			this.setTimer();
		},
		methods:{
			toAdvice:function(){
// 				layer.open({
// 					  type: 2, 
// 					  skin: 'layui-layer-rim', //加上边框
// 					  area: ['1120px', '530px'], //宽高
// 					  content: '/zlz/advice.html'
// 				});
				location.href='/zlz/advice.html';
			},
			getNewAdvice:function(){
				axios.get("/msg/new")
					.then(
						res => {
							if(res.data.data!=0){
								this.content="new";
							}else{
								this.content="";
							}
						}
					)
					.catch(
						error => {
							console.log(error);
							clearInterval(this.timer);
						}
					);
			},
			setTimer:function(){
				this.timer = setInterval(
						() => {
							this.getNewAdvice();
				},10000)
			},
			toMycourse:function(){
				location.href = "/xingqilin/classShow.html?id="+this.id;
			}
			
		}
	})
</script>